package com.cml.dm.admin.event;

import com.cml.dm.admin.service.TaskExecutorServiceFactory;
import com.cml.dm.engine.context.DmContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
@Async
@Slf4j
public class RecoveryEventListener  implements ApplicationListener<RecoveryEvent> {
    @Autowired
    private TaskExecutorServiceFactory taskExecutorServiceFactory;
    @Override
    public void onApplicationEvent(RecoveryEvent event) {
        DmContext.getThreadPool(event.getDmExeLogger().getTaskID()).execute(new TaskRunable(taskExecutorServiceFactory,event.getDmExeLogger(),event.getExtParameters()));
    }
}
